package cn.ecnu.faker.inject;

import cn.ecnu.faker.util.FakerUtil;
import cn.ecnu.mapper.ConsultRecordMapper;
import cn.ecnu.mapper.UserMapper;
import cn.ecnu.pojo.ConsultRecord;
import cn.ecnu.pojo.User;
import com.github.javafaker.Faker;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.Date;

@SpringBootTest
public class MainApplication {

    @Resource
    ConsultRecordMapper consultRecordMapper;

    @Resource
    UserMapper userMapper;

    //
//    @Test
    public void addConsultRecord() {
        for (int i = 0; i < 10; i++) {
            ConsultRecord consultRecord = new ConsultRecord();
            consultRecord.setDatetime(FakerUtil.generateDate());  consultRecord.setFromId(FakerUtil.generateId());
            consultRecord.setDuration(FakerUtil.generateAge()); consultRecord.setFromGrade(FakerUtil.generateGrade());
            consultRecord.setFromComment(FakerUtil.generateComment()); consultRecord.setToDiagnosis(FakerUtil.generateDiagnosis());
            consultRecord.setToComment(FakerUtil.generateComment());
            consultRecordMapper.insertConsultRecord(consultRecord);
        }
    }

    @Test
    public void addUser() {
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setUserNickname(FakerUtil.generateNickName());
            user.setUserName(FakerUtil.generatePersonName());
            user.setUserPhone(FakerUtil.generatePhone());
            user.setRole(FakerUtil.generateRole());
            user.setUserGender(FakerUtil.generateGender());
            user.setUserAge(FakerUtil.generateAge());
            user.setUserIdentity(FakerUtil.generateTitleId());
            user.setUserEmail("10182100322@stu.ecnu.edu.cn");
            user.setUserPassword("123");
            user.setUserWorkPlace(FakerUtil.generateAdd());
            user.setUserPosition(FakerUtil.generateAdd());
            userMapper.insertUser(user);
        }
    }


}
